package expression;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexMatches {
    private static final String REGEX = "张";
    private static final String INPUT = "张成四";
    private static Pattern pattern;
    private static Matcher matcher;

    public static void main(String args[]) {
        pattern = Pattern.compile(REGEX);
        matcher = pattern.matcher(INPUT);

        System.out.println("Current REGEX is: " + REGEX);
        System.out.println("Current INPUT is: " + INPUT);

        //lookingAt不需要整个序列都匹配，存在匹配的项即可
        System.out.println("lookingAt(): " + matcher.lookingAt());

        //matcher要求整个序列都匹配
        System.out.println("matches(): " + matcher.matches());
    }
}